using System;
using System.Collections.Generic;
using NaughtyAttributes;
using SimpleJSON;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Gj
{
    public class MapTagHelper : NodeHelper
    {
        public GameObject item;
        public List<GameObject> list;
        protected override BindDataType bindDataType => BindDataType.List;

        protected override void BindData(JSONArray arr)
        {
            if (arr == null) return;
            var all = 0;
            for (var i = 0; i < arr.Count; i++)
            {
                var id = arr[i].Value;
                if (list.Count <= all) list.Add(Instantiate(item, transform));
                var o = list[all];
                o.GetComponent<MapTagItemHelper>().SetData(MapTagTools.Get(id));
                o.SetActive(true);
                all++;
            }

            for (var i = all; i < list.Count; i++) list[i].SetActive(false);

        }
    }
}